﻿using System;

namespace PersonExercises
{
    class TestPerson
    {
        public void SomePropChanged(object sender, PropertyChangedEventArgs args)
        {
            Console.WriteLine("{0} property is changed! {1} -> {2}",
                args.NameOfPropertyChanged,args.OldValue,args.NewValue);
        }

        public void EGNHandler(object obj, EventArgs args)
        {
            Console.WriteLine("EGN has a value: "+(obj as Person).Egn);
        }

        static void Main()
        {
            Person pesho = new Person("pesho","subev",true,new DateTime(1988,04,18));
            TestPerson test = new TestPerson();
            pesho.PropertyChanged += test.SomePropChanged;
            pesho.FirstName = "Pesho";
            pesho.BirthDate = new DateTime(1988, 04, 18); //wont appear
            pesho.Male = false;
            pesho.LastName = "Subev";
            pesho.LastName = "Subev";   //wont appear
            pesho.BirthDate = new DateTime(1988, 01, 18);
            pesho.EGNChanged += test.EGNHandler;
            pesho.Egn = 8804180542;
            pesho.Egn = 8804180542; //will apear
        }
    }
}
